<?php
/*******************************************************************
 * [JishiGou] (C)2005 - 2099 Cenwor Inc.
*
* This is NOT a freeware, use is subject to license terms
*
* @Filename vote.logic.php $
*
* @Author http://www.jishigou.net $
*
* @Date 2013-04-02 18:45:57 1284608225 1686178128 26713 $
*******************************************************************/




if(!defined('IN_JISHIGOU')) {
	exit('invalid request');
}

class OfferLogic
{



	function find($param)
	{

	}

	function id2subject($vid)
	{

	}


	function is_exists($vid)
	{

	}


	function getPicUrl($pid){

	}




	function create($post, &$ret)
	{

	}


	function modify($post)
	{
	
	}


	function get_vote_item($vid, $uid, $isanonymous=0)
	{
	
	}


	



	function delete($ids)
	{


	}


	




	


	function upload_pic($id){

		$image_name = $id.".jpg";
		$image_path = RELATIVE_ROOT_PATH . 'images/vote/'.face_path($id);
		$image_file = $image_path . $image_name;

		if (!is_dir($image_path))
		{
			jlib('io')->MakeDir($image_path);
		}
		Load::lib('upload');
		$UploadHandler = new UploadHandler($image_path,'image',true);
		$UploadHandler->setMaxSize(1000);
		$UploadHandler->setNewName($image_name);
		$result=$UploadHandler->doUpload();

		if($result)
		{
			$result = is_image($image_file);
		}
		if(!$result)
		{
			unlink($image_file);
			return false;
		}else{
			if($this->Config['ftp_on']) {
				$ftp_key = randgetftp();
				$get_ftps = ConfigHandler::get('ftp');
				$site_url = $get_ftps[$ftp_key]['attachurl'];
				$ftp_result = ftpcmd('upload',$image_file,'',$ftp_key);
				if($ftp_result > 0) {
					jlib('io')->DeleteFile($image_file);
					$image_file = $site_url .'/'. str_replace('./','',$image_file);
				}
			}
			DB::update('vote_field', array('img' => $image_file), array('vid' => $id));
		}
		return true;
	}
}

?>